package unit4.part13;

public class Average {
    static double compute(double... numbers) {
        if (numbers == null || numbers.length == 0) {
            return 0;
        }
        double total = 0.0;
        for (double number : numbers) {
            total += number;
        }
        return total / numbers.length;
    }

    public static void main(String[] args) {
        System.out.println(compute(null));
        System.out.println(compute());
        System.out.println(compute(1));
        System.out.println(compute(1, 2));
        System.out.println(compute(1, 2, 3));
    }
}
